# $Id$
# Maintainer: Ionut Biru <ibiru@archlinux.org>

pkgname=js
pkgver=24.2.0
pkgrel=4
pkgdesc="JavaScript interpreter and libraries"
arch=(i686 x86_64)
url="https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Releases/24"
license=(MPL)
depends=(nspr gcc-libs readline zlib)
makedepends=(python2 zip libffi)
options=(!staticlibs)
source=(http://ftp.mozilla.org/pub/mozilla.org/js/mozjs-$pkgver.tar.bz2)
md5sums=('5db79c10e049a2dc117a6e6a3bc78a8e')

prepare() {
  cd mozjs-$pkgver/js/src

  rm -r editline
  rm -r ctypes/libffi

  # Fix incompatibility with Perl 5.22
  sed -i 's/(defined\((@TEMPLATE_FILE)\))/\1/' config/milestone.pl
}

build() {
  unset CPPFLAGS
  CXXFLAGS+=' -fno-delete-null-pointer-checks'
  cd mozjs-$pkgver/js/src
  ./configure --prefix=/usr --with-system-nspr --enable-system-ffi \
     --enable-readline --enable-threadsafe
  make
}

check() {
  cd mozjs-$pkgver/js/src
  make check
}

package() {
  cd mozjs-$pkgver/js/src
  make DESTDIR="$pkgdir" install
  find "$pkgdir"/usr/{lib/pkgconfig,include} -type f -exec chmod -x {} +
}

# vim:set ts=2 sw=2 et:
